package com.sanmu.factory;

import com.sanmu.bean.Monster;

import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0
 * @Author xinnian
 * @Date 2024/9/13 17:14
 * @注释
 * @create: 2024-09-13 17:14
 */

public class MyInstanceFactory {
    private  Map<String, Monster> monster_map;

    //通过普通代码块进行初始化
    {
        monster_map = new HashMap<>();
        monster_map.put("monster10", new Monster(10, "小兔子", "sanmu"));
    }

    public  Monster getMonster(String key) {
        return monster_map.get(key);
    }


}
